package yunhe.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import yunhe.biz.ReceiptBiz;
import yunhe.entity.ReceiptFlow;
@WebServlet(name="checkByDateServlet",urlPatterns="/checkByDateServlet")
public class checkByDateServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	
		String begin = request.getParameter("begin");
		String end = request.getParameter("end");
		ReceiptBiz receiptbiz = new ReceiptBiz();
		HttpSession session = request.getSession();
		PrintWriter out = response.getWriter();
		List<ReceiptFlow> receiptflows = receiptbiz.searchRecByDate(begin, end);
		
		if(receiptflows!= null) {
			session.setAttribute("beging", begin);
			session.setAttribute("endd", end);
			session.setAttribute("receiptflows",receiptflows);
		}
		else{
			response.sendRedirect("index.jsp");
		}
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}
}
